package hn.cch.mybatis.mapper;

import hn.cch.mybatis.entity.TableEntity;
import org.apache.ibatis.annotations.Arg;
import org.apache.ibatis.annotations.ConstructorArgs;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.cursor.Cursor;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

@Mapper
public interface TableMapper {

    @Results(id = "tableResult", value = {
        @Result(
            property = "columnName", javaType = String.class,
            column = "column_name", jdbcType = JdbcType.VARCHAR
        ),
    })
    @ConstructorArgs(value = {
        @Arg(
            javaType = String.class,
            column = "column_name", jdbcType = JdbcType.VARCHAR
        )
    })


    @Select(value = "select column_name from table_entity")
    public List<TableEntity> selectTableList();

    @Select(value = "select column_name from table_entity")
    public Cursor<TableEntity> selectTableCursor();

    @Select(value = "select count(*) from table_entity")
    public int selectTableCount();

}
